#include "reg_map_check.h"
#include "sys_def.h"
#include "user_mb_app.h"
extern sys_reg_st g_sys;

uint8_t return_temp_hiacl_chk(uint16_t pram)
{
    if (pram > g_sys.config.alarm[ACL_LO_TEMP_RETURN].alarm_param) {
        return (1);
    }
    return (0);
}

uint8_t return_temp_lowacl_chk(uint16_t pram)
{
    if (pram < g_sys.config.alarm[ACL_HI_TEMP_RETURN].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t return_hum_hiacl_chk(uint16_t pram)
{
    if (pram > g_sys.config.alarm[ACL_LO_HUM_RETURN].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t return_hum_lowacl_chk(uint16_t pram)
{
    if (pram < g_sys.config.alarm[ACL_HI_HUM_RETURN].alarm_param) {
        return (1);
    }
    return (0);
}

uint8_t power_frq_hi_chk(uint16_t pram)
{
    if (pram > g_sys.config.alarm[ACL_IPM_LO_FD].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t power_frq_lo_chk(uint16_t pram)
{
    if (pram < g_sys.config.alarm[ACL_IPM_HI_FD].alarm_param) {
        return (1);
    }
    return (0);
}

uint8_t power_a_hi_chk(uint16_t pram)
{
    if (pram > g_sys.config.alarm[ACL_IPM_A_LOW].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t power_a_lo_chk(uint16_t pram)
{
    if (pram < g_sys.config.alarm[ACL_IPM_A_HIGH].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t power_b_hi_chk(uint16_t pram)
{
    if (pram > g_sys.config.alarm[ACL_IPM_B_LOW].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t power_b_lo_chk(uint16_t pram)
{
    if (pram < g_sys.config.alarm[ACL_IPM_B_HIGH].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t power_c_hi_chk(uint16_t pram)
{
    if (pram > g_sys.config.alarm[ACL_IPM_C_LOW].alarm_param) {
        return (1);
    }
    return (0);
}
uint8_t power_c_lo_chk(uint16_t pram)
{
    if (pram < g_sys.config.alarm[ACL_IPM_C_HIGH].alarm_param) {
        return (1);
    }
    return (0);
}
// uint8_t cool0_temp_hi_chk(uint16_t pram)
//{
//	if(pram > g_sys.config.alarm[ACL_COIL_BLOCKING].alarm_param)
//		{
//				return(1);
//		}
//		return(0);
//}

uint8_t acConfalarmHighTempHandle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.alarmHighTemp.Flag = TRUE;
    return 1;
}
uint8_t acConfalarmLowTempHandle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.alarmLowTemp.Flag = TRUE;
    return 1;
}
uint8_t acConfalarmHighHumidityHandle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.alarmHighHumidity.Flag = TRUE;
    return 1;
}
uint8_t acConfalarmLowHumidityHandle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.alarmLowHumidity.Flag = TRUE;
    return 1;
}
uint8_t acConfTempSet0Handle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.TempSet0.Flag = TRUE;
    return 1;
}
uint8_t acConfTempRange0Handle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.TempRange0.Flag = TRUE;
    return 1;
}
uint8_t acConftempStagnationZone0Handle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.tempStagnationZone0.Flag = TRUE;
    return 1;
}
uint8_t acConfTempSet1Handle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.TempSet1.Flag = TRUE;
    return 1;
}
uint8_t acConfTempRange1Handle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.TempRange1.Flag = TRUE;
    return 1;
}
uint8_t acConftempStagnationZone1Handle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.tempStagnationZone1.Flag = TRUE;
    return 1;
}
uint8_t acConfpowerOnHandle(uint16_t pram)
{
    g_sys.config.mbm_Conf.AC.powerOn.Flag = TRUE;
    return 1;
}

uint8_t AC_Conf_Write(uint16_t pram, uint8_t Type)
{
    extern mbm_read_st mbm_read_table_01[];
    uint8_t            k;

    switch (Type) {
        case 0x00:
        {
            for (k = 0; k < mbm_read_table_01[MBM_DEV_AC_ADDR].reg_w_cnt; k++) {
                *(mbm_read_table_01[MBM_DEV_AC_ADDR].w_pt[k].conf_Flag) = FALSE;
            }
            break;
        }
        case 0x01:
        {
            for (k = 0; k < mbm_read_table_01[MBM_DEV_AC_ADDR].reg_w_cnt; k++) {
                *(mbm_read_table_01[MBM_DEV_AC_ADDR].w_pt[k].conf_Flag) = TRUE;
            }
            break;
        }
        case 0x02:
        {
            if (mbm_read_table_01[MBM_DEV_AC_ADDR].reg_w_cnt == 0) {
                return (0);
            } else {
                // g_sys.status.general.TEST|=0x40;
                for (k = 0; k < mbm_read_table_01[MBM_DEV_AC_ADDR].reg_w_cnt; k++) {
                    if (pram == mbm_read_table_01[MBM_DEV_AC_ADDR].w_pt[k].Conf_addr) {
                        // g_sys.status.general.TEST|=0x80;
                        *(mbm_read_table_01[MBM_DEV_AC_ADDR].w_pt[k].conf_Flag) = TRUE;
                    }
                }
            }
            break;
        }
        default:
            break;
    }
    return (1);
}
